'use strict';

const path = require('path')

module.exports = appInfo => {

  return {
    // use for cookie sign key, should change to your own and keep security
    keys: appInfo.name + '_1529651842694_4538',

    // add your config here
    middleware: [/*'checkLogin', 'token'  , "authz" */ ],
     io : {
      init: { }, // passed to engine.io
      namespace: {
        '/': {
          connectionMiddleware: ['auth'],
          packetMiddleware: ["filter"],
        },
        "/room": {
          connectionMiddleware: [],
          packetMiddleware: [],
        }
      }
    }, 
    cluster: {
      listen: {
        port: 1221,
        hostname: '127.0.0.1',
      },
    },

    static: {
      prefix: '/',
    },

    view: {
      root: [
        path.join(appInfo.baseDir, 'app/view'),
        //path.join(appInfo.baseDir, 'path/to/another'),
      ].join(','),
      view: {
        defaultViewEngine: 'vue',
      },
    },

    security: {
      csrf: {
        ignore: ['/api/v1/upload', '/api/v1/logout', "/api/v1/user"],
        enable: false,
        headerName: 'x-csrf-token',

        useSession: true, // 默认为 false，当设置为 true 时，将会把 csrf token 保存到 Session 中
        cookieName: 'csrfToken', // Cookie 中的字段名，默认为 csrfToken
        sessionName: 'csrfToken', // Session 中的字段名，默认为 csrfToken
      },
    },

    mongoose: {
      url: 'mongodb://localhost/mydb1',
      options: {
        useMongoClient: true,
      },
    },

    logger: {
      level: 'DEBUG',
    },

    session: {
      key: 'modularizeSite',
      maxAge: 30 * 60 * 1000,
      httpOnly: false,
      encrypt: true,
      rolling: true,
    },
  }

};
